import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { ServicesVO, ServicesForm, ServicesQuery, AuditBo } from '@/api/business/services/types';

/**
 * 查询服务信息列表
 * @param query
 * @returns {*}
 */

export const listServices = (query?: ServicesQuery): AxiosPromise<ServicesVO[]> => {
  return request({
    url: '/system/services/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询服务信息详细
 * @param id
 */
export const getServices = (id: string | number): AxiosPromise<ServicesVO> => {
  return request({
    url: '/system/services/' + id,
    method: 'get'
  });
};

/**
 * 新增服务信息
 * @param data
 */
export const addServices = (data: ServicesForm) => {
  return request({
    url: '/system/services',
    method: 'post',
    data: data
  });
};

/**
 * 修改服务信息
 * @param data
 */
export const updateServices = (data: ServicesForm) => {
  return request({
    url: '/system/services',
    method: 'put',
    data: data
  });
};

/**
 * 删除服务信息
 * @param id
 */
export const delServices = (id: string | number | Array<string | number>) => {
  return request({
    url: '/system/services/' + id,
    method: 'delete'
  });
};

// 审核服务
export function auditServices(data: AuditBo) {
  return request({
    url: '/system/services/audit',
    method: 'post',
    data: data
  });
}
